package com.extremeforce.diy;

import com.extremeforce.IguangActivity;
import com.extremeforce.R;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.TextView;

public class ExitDialog extends Dialog{
	private Activity context = null;
	
	public ExitDialog(Activity context) {
		super(context,R.style.cjx_exit_dialog);
		this.context = context;
		LayoutInflater inflater = LayoutInflater.from(context);
		View view = inflater.inflate(R.layout.exitdialoglayout,null);
		this.setContentView(view);
		
		//
		TextView exitTextView = (TextView)view.findViewById(R.id.cjx_exit_confirm_button);
		
		exitTextView.setOnClickListener(new View.OnClickListener(){

			public void onClick(View v) {
				
				Intent main = new Intent();
				main.setClass(ExitDialog.this.context,IguangActivity.class);
				ExitDialog.this.context.startActivity(main);
				
				Intent i = new Intent(Intent.ACTION_MAIN);
				i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				i.addCategory(Intent.CATEGORY_HOME);
				ExitDialog.this.context.startActivity(i);
			}
			
		});
		
		TextView cancelTextView = (TextView)view.findViewById(R.id.cjx_exit_cancel_button);
		
		cancelTextView.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				ExitDialog.this.dismiss();
			}
		});
	}

}
